package com.edais.dao;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Repository;

import com.edais.domain.OrderBalance;
import com.edais.domain.PerMatchCredit;
import com.edais.domain.PreMatchLoan;
import com.edais.persistence.PerMatchMapper;

@Repository

public class PerMatchDao {
	@Autowired
	private PerMatchMapper perMatchMapper;

	/**
	 * 根据订单id获取预匹配订单余额
	 */
	public OrderBalance getOrderBalanceByOrderId(Integer orderId) throws Exception {
		return this.perMatchMapper.getOrderBalanceByOrderId(orderId);
	}

	/**
	 * 生成预匹配订单余额
	 */
	public void insertOrderBalanceInfo(OrderBalance orderBalance) throws Exception{
		this.perMatchMapper.insertOrderBalanceInfo(orderBalance);
	}
	
	/**
	 * 根据订单id更新预匹配订单余额
	 */
	public void updateOrderBalanceInfoByOrderId(OrderBalance orderBalance) throws Exception{
		this.perMatchMapper.updateOrderBalanceInfoByOrderId(orderBalance);
	}
	
	/**
	 * 根据订单余额获取预匹配标的
	 */
	public List<PreMatchLoan> getPreMatchLoanByOrderBalance(PreMatchLoan preMatchLoan) throws Exception{
		return this.perMatchMapper.getPreMatchLoanByOrderBalance(preMatchLoan);
	}
	
	/**
	 * 生成预匹配债券列表
	 */
	public void insertPerMatchCrdit(PerMatchCredit preMatchCredit) throws Exception{
		this.perMatchMapper.insertPerMatchCrdit(preMatchCredit);
	}
	
	/**
	 * 根据订单id删除预匹配债券
	 */
	public void deletePerMatchCrditByOrderId(Integer orderId) throws Exception{
		this.perMatchMapper.deletePerMatchCrditByOrderId(orderId);
	}
	
	/**
	 * 根据订单id获取预匹配债券
	 */
	public List<PerMatchCredit> getPreMatchCreditByOrderId(Integer orderId) throws Exception{
		return this.perMatchMapper.getPerMatchCrditByOrderId(orderId);
	}
}
